package com.telkomsigma.spring.hibernate.persistence.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the football_team database table.
 * 
 */
@Entity
@Table(name="football_team")
public class FootballTeam implements Serializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String name;
	private List<TPlayer> players;
	private List<TPlayer> captains;

    public FootballTeam() {
    }


	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(length=20)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	//bi-directional many-to-one association to Player
	@OneToMany(mappedBy="footballTeam", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
	public List<TPlayer> getPlayers() {
		return this.players;
	}

	public void setPlayers(List<TPlayer> players) {
		this.players = players;
	}

	@OneToMany(fetch = FetchType.EAGER)
	@JoinTable(name="team_capt", joinColumns = {@JoinColumn(name="team_id")},
	inverseJoinColumns = {@JoinColumn(name="player_id")})
	public List<TPlayer> getCaptains() {
		return captains;
	}


	public void setCaptains(List<TPlayer> captains) {
		this.captains = captains;
	}
	
	
}